home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / util / misc / ddli2_02.lha / DDLI.C < prev    next >
C/C++ Source or Header  |  1993-04-04  |  6KB  |  157 lines

  1. /*
  2.  *  DDLI.c:  The Duniho and Duniho Life Pattern Indicator V 2.02
  3.  *  by Fergus Duniho
  4.  *  Copyright (c) 1992, 1993 Fergus Duniho
  5.  */
  6.  
  7. /*
  8.  * If your compiler does not have the command "strdup",
  9.  * which is common in C compilers but not part of ANSI
  10.  * C, uncomment the next #include statement.
  11.  */
  12. /* #include "strdup.c" */
  13.  
  14. #include "fpdio.c"
  15. #include "qst.c"
  16.  
  17. #define XN E ? "Extraverted" : "Introverted"
  18.  
  19. /*
  20.  * If you don't use an Amiga, your printer device
  21.  * might be called "PRN" instead of "PRT:". If it
  22.  * is, change the next #define.
  23.  */
  24. #define prtdev "PRT:"
  25. #define QFILE "DDLI.QST"
  26.  
  27. main () {
  28.     int i, col, size, A, L, L1, L2, pr[14],
  29.     E, I, S, N, T, F, J, P, ES, EN, ET, EF, R;
  30.     char line[256], nline[512], *name, *fname, *Version,
  31.      *LP[16] = {"INTP", "INTJ", "INFP", "INFJ",
  32.             "ISTP", "ISTJ", "ISFP", "ISFJ",
  33.             "ENTP", "ENTJ", "ENFP", "ENFJ",
  34.             "ESTP", "ESTJ", "ESFP", "ESFJ"},
  35.      *PF[2] = {"Intuition", "Sensing"},
  36.      *JF[2] = {"Thinking", "Feeling"},
  37.      *text1 = "Your %s function is %s %s.";
  38.     FILE *fptr;
  39.     qst *Q;
  40.  
  41.     wrapwrite (stdout, 0, 0, 20, "How many columns does your screen have?", 0);
  42.     col = fgetp(stdin);
  43.  
  44.     wrapwrite (stdout, 0, 0, col,
  45.     "\n\"The Duniho and Duniho Life Pattern Indicator\"",
  46.     "V2.02\nBy Fergus Duniho. Copyright (c) 1992, 1993",
  47.     "Fergus Duniho.\n\nMost of the questions are drawn from",
  48.     "and based on those in Terence Duniho's \"Preference",
  49.     "Patterns Questionaire\" and his book _Wholeness Lies",
  50.     "Within_. Fergus is responsible for the choice of questions.",
  51.     "\n\nThis product is freeware. Send comments, bug reports,",
  52.     "reports on accuracy, and suggestions for improvement to",
  53.     "Fergus Duniho at F.DUNIHO on GEnie and",
  54.     "fdnh@troi.cc.rochester.edu on the Internet.\n\n", 0);
  55.  
  56.     size = Linefeeds(QFILE) / 3;
  57.     Q = new_qnode(0);
  58.     Q->pv = Q->nx = Q;
  59.     Version = Get_QList (QFILE, Q, size);
  60.  
  61.     wrapwrite (stdout, 0, 0, col, "What is your name?", 0);
  62.     name = clone_line(stdin, 80);
  63.  
  64.     wrapwrite (stdout, 0, 0, col,
  65.     "Enter an integer as a seed value for the random # generator", 0);
  66.     srand (fgetp(stdin));
  67.     Q = RND_QList (Q, size);
  68.  
  69.     AskQuestions (Q, col);
  70.     for (i = 0; i < 14; i++) /* Initializes Preference Scores to Zero */
  71.     pr[i] = 0;
  72.     for (Q = Q->nx; Q->num > 0; Q = Q->nx) /* Calculates Scores */
  73.     pr[Q->ans]++;
  74.  
  75.     wrapwrite (stdout, 0, 0, col,
  76.     "Send output to (1) Screen, (2) Printer, or (3) File?", 0);
  77.     do {
  78.     A = fgetp(stdin);
  79.     if (A == 1)
  80.         fptr = stdout;
  81.     else if (A == 2) {
  82.         WrOpen (fptr, prtdev);
  83.         col = 75;
  84.     }
  85.     else if (A == 3) {
  86.         wrapwrite (stdout, 0, 0, col, "Please enter a file name.", 0);
  87.         fname = clone_line(stdin, 32);
  88.         WrOpen (fptr, fname);
  89.     }
  90.     else
  91.         wrapwrite (stdout, 0, 0, col,
  92.         "Please enter a 1, a 2, or a 3.", 0);
  93.     } while (A < 1 || A > 3);
  94.  
  95.     E = pr[1]; I = pr[2]; S = pr[3]; N = pr[4];
  96.     T = pr[5]; F = pr[6]; J = pr[7]; P = pr[8];
  97.     ES = pr[12]; EN = pr[13]; ET = pr[11]; EF = pr[10];
  98.     sprintf (nline, "%s's scores on the main set of questions:\n"
  99.             "\n\nExtraversion (E): %2d    %2d :(I) Introversion"
  100.             "\nSensing      (S): %2d    %2d :(N) iNtuition"
  101.             "\nThinking     (T): %2d    %2d :(F) Feeling"
  102.             "\nJudging      (J): %2d    %2d :(P) Preceiving\n",
  103.             name, E, I, S, N, T, F, J, P);
  104.     wrapwrite (fptr, 0, 0, col, nline, 0);
  105.     L = 8 * (E > I) + 4 * (S > N) + 2 * (F > T) + (J > P);
  106.     R = (((L & 1) == 1) == ((L & 8) == 8)); E = (E > I);
  107.     fprintf (fptr, "%s scored as an %s.\n", name, LP[L]);
  108.     fprintf (fptr, "\nAssuming that you are an %s,\n", LP[L]);
  109.     sprintf (line, text1, "DOMINANT", XN, R ? JF[(L & 2) == 2] : PF[(L & 4) == 4]);
  110.     wrapwrite (fptr, 0, 5, col, line, 0);
  111.     sprintf (line, text1, "AUXILIARY", !XN, R ? PF[(L & 4) == 4] : JF[(L & 2) == 2]);
  112.     wrapwrite (fptr, 0, 5, col, line, 0);
  113.     sprintf (line, text1, "TERTIARY", XN, R ? PF[(L & 4) != 4] : JF[(L & 2) != 2]);
  114.     wrapwrite (fptr, 0, 5, col, line, 0);
  115.     sprintf (line, text1, "INFERIOR", !XN, R ? JF[(L & 2) != 2] : PF[(L & 4) != 4]);
  116.     wrapwrite (fptr, 0, 5, col, line, 0);
  117.     if (A == 1) {
  118.     wrapwrite (stdout, 0, 0, col, "Hit <ENTER> or <RETURN> to see",
  119.     "your results on the supplementary questions.", 0);
  120.     while (fgetc(stdin) != '\n');
  121.     }
  122.     sprintf (nline, "\n%s's scores on the supplementary questions:\n\n"
  123.             "Extraverted Thinking / Introverted Feeling   : %d\n"
  124.             "Extraverted Feeling / Introverted Thinking   : %d\n\n"
  125.             "Extraverted Intuition / Introverted Sensing  : %d\n"
  126.             "Extraverted Sensing / Introverted Intuition  : %d\n\n"
  127.             "Rationality (Dominant Judging Function)      : %d\n"
  128.             "A-rationality (Dominant Perceiving Function) : %d\n",
  129.             name, ET, EF, EN, ES, pr[9], pr[0]);
  130.     wrapwrite (fptr, 0, 0, col, nline, 0);
  131.     if (R = (pr[9] > pr[0]))
  132.     L1 = 9 + (EF > ET) * 2 + (EN > ES) * 4;
  133.     else
  134.     L1 = 8 + (EF < ET) * 2 + (EN < ES) * 4;
  135.     L2 = L1 ^ 15;
  136.     sprintf (line, "According to these scores, %s could be a dominant %s "
  137.         "who extraverts %s and %s, and who introverts %s and %s. "
  138.         "Thus, %s might be an %s or an %s.", name,
  139.         R ? "judger" : "perceiver", JF[EF > ET], PF[ES > EN],
  140.         JF[EF < ET], PF[ES < EN], name, LP[L1], LP[L2]);
  141.     if ((L == L1) || (L == L2))
  142.     sprintf (nline, "%s These results corroborate your score as an %s.", line, LP[L]);
  143.     else
  144.     sprintf (nline, "%s These results conflict with the evaluation of %s as an %s.", line, name, LP[L]);
  145.     wrapwrite (fptr, 0, 0, col, nline, 0);
  146.     fclose (fptr);
  147.  
  148.     strncpy (line, name, 8);
  149.     strcat (line, ".dar");
  150.     printf ("\nSending raw scores to %s.\n", line);
  151.     WrOpen (fptr, line);
  152.     fprintf (fptr, "%s\n", Version);
  153.     for (Q = Q->nx; Q->num > 0; Q = Q->nx)
  154.     fprintf (fptr, "%d %d\n", Q->num, Q->ans);
  155.     fclose (fptr);
  156. }
  157.